<script setup>
import { useRouter } from 'vue-router';

const router = useRouter();
const handleClick = () => {
  navigator.mediaDevices.getUserMedia({ audio: true })
  .then((stream) => {
    router.push('/chatvoice');
  })
  .catch((error) => {
    alert('请授予麦克风权限');
    console.error('无法获取麦克风权限:', error);
  });
}
</script>

<template>
    <div>Home</div>
    <button @click="handleClick">语音通话</button>
</template>

<style lang="sass" module>
</style>